'''
文件为批量修改annotation 内容
'''

import os
import xml.etree.ElementTree as Etree


rootpath="/media/gis/data/jupyterlabhub/gitcode/hrx/dataset"
annpath=os.path.join(rootpath,"biaoqian")
imgpath=os.path.join(rootpath,"shujuji")

annolist = os.listdir(annpath)
imglist = os.listdir(imgpath)

for anno in annolist:
    anpath=os.path.join(annpath,anno) 
    conxml=Etree.parse(anpath)
    timg_path=conxml.find("path").text
    timg_path=timg_path.replace("\\","/").replace("E:/lumian/","")
    tpath=os.path.join(rootpath,timg_path)
    if (os.path.exists(tpath)):
        conxml.find("path").text=timg_path
        conxml.write(anpath)

